﻿@using CloudStorageLight.Web.Models
@using CloudStorageLight.Core
@model LoginViewModel
@using Microsoft.Owin.Security
@{
    ViewBag.Title = "Log in";
    Layout = "~/Views/Shared/_LayoutAccount.cshtml";
    var withDomainMode = string.IsNullOrEmpty(CloudStorageLight.Core.BlobService.GetCurrentDomain()) && CloudStorageLight.Core.SystemSettings.Instance.MultiDomain;

    CloudAccount cloudAccount = null;
    if (!withDomainMode){
        cloudAccount = CloudStorageLight.Core.BlobService.GetCurrentCloudAccount();
    }

}

<h2>@ViewBag.Title.</h2>
<div class="row">
    <div class="col-md-10">
        <section id="loginForm">
            <form class="form-horizontal" method="POST" action="Login?returnUrl=@(ViewBag.ReturnUrl)">
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                @Html.HiddenFor(x=>x.ClientToken)

                @if (withDomainMode)
                {
                    <div class="form-group">
                        <span class="col-md-3 control-label">@(CloudStorageLight.Core.Web.ViewMessages.MsgCloudAccount)</span>
                        <div class="col-md-5">
                            @Html.TextBoxFor(m => m.CloudAccount, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.CloudAccount, "", new { @class = "text-danger" })
                        </div>
                        <div class="col-md-4">
                        </div>
                    </div>
                }
                <div class="form-group">
                    <span class="col-md-3 control-label">@(CloudStorageLight.Core.Web.ViewMessages.MsgEmail)</span>
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
                    </div>
                    <div class="col-md-4">
                        <div class="checkbox">
                            @Html.CheckBoxFor(m => m.AdminRole, new { tabindex=-1 })
                            <span>@(CloudStorageLight.Core.Web.ViewMessages.MsgAdminRole)</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <span class="col-md-3 control-label">@(CloudStorageLight.Core.Web.ViewMessages.MsgPassword)</span>
                    <div class="col-md-5">
                        @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-8">
                        <div class="checkbox">
                            @Html.CheckBoxFor(m => m.RememberMe)
                            <span>@(CloudStorageLight.Core.Web.ViewMessages.MsgRememberMe)</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-6">
                        <button id="login" type="submit" class="btn btn-default">
                            @CloudStorageLight.Core.Web.ViewMessages.MsgLogin
                        </button>
                    </div>
                </div>
            </form>
        </section>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        if (typeof Storage !== "undefined") {
            var token = localStorage.getItem("clientToken");
            if (token != null) $("#ClientToken").val(token);
        }

    });
</script>
